// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//

#if !defined(AFX_STDAFX_H__B226C229_F0B5_40E6_9A07_2306D9005B5F__INCLUDED_)
#define AFX_STDAFX_H__B226C229_F0B5_40E6_9A07_2306D9005B5F__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define VC_EXTRALEAN		// Exclude rarely-used stuff from Windows headers

#include <afxwin.h>         // MFC core and standard components
#include <afxext.h>         // MFC extensions
#include <afxdisp.h>        // MFC Automation classes
#include <afxdtctl.h>		// MFC support for Internet Explorer 4 Common Controls
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>			// MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT

#include <afxsock.h>		// MFC socket extensions

#include "MyRichEdit.h"

#define USER_TIMER1		1
#define SEND_DATA		0x01
#define RECV_DATA		0x02
#define RX_BUFF			2048
#define WM_UPDATEMSG	(WM_USER+101)
#define WM_CLOSEMSG		(WM_USER+102)
#define WM_UPDATECOUNT	(WM_USER+103)
#define MAX_CLIENT		16

CString HexToStr(BYTE *btData, int nLength);

bool IsValidChar(char ch);

char GetCharFromHex(char hichar,char lochar);

CString GetAsciiStr(CString HexStr);

CString GetHexStr(CString AsciiStr);

void PackSendBuff( char *buffer, CString strMsg );

#define MaxQueue	8192

typedef struct
{
	unsigned int front;
	unsigned int rear;
	unsigned char NetRecvBuff[MaxQueue];
}NET_RECV_QUEUE;

bool QueueNotEmpty(NET_RECV_QUEUE *pQueue);

int Check_QUEUE_Space(NET_RECV_QUEUE *pQueue, unsigned int uiSize, unsigned int MaxLen);

int InQueue(unsigned char *pData, NET_RECV_QUEUE *pQueue, int nLen);

int OutQueue(unsigned char *pData, NET_RECV_QUEUE *pQueue, int nLen);

int ReadOneMsg(unsigned char *NetRecvBuff, NET_RECV_QUEUE *pQueue);

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STDAFX_H__B226C229_F0B5_40E6_9A07_2306D9005B5F__INCLUDED_)
